<?php

/**
 * Created by PhpStorm.
 * User: wenqiang.yq@gmail.com
 * Date: 16-2-29
 * Time: 下午9:56
 */
namespace ElasticSearch;

class EsBase
{
    protected $index = "";
    protected $hosts = "";
    protected $type = "";

    public function __construct($hosts = "", $index = "", $type = "")
    {
        $this->hosts = $hosts;
        $this->index = $index;
        $this->type = $type;
    }

    /**
     * bulk批量操作请求
     * @param $jsonStr
     * @return mixed|string
     */
    protected function bulk($jsonStr)
    {
        $uri = EsTools::specialUri($this->hosts, "_bulk");
        return EsHttp::post($uri, $jsonStr);
    }


    protected function info($index, $type)
    {
        return array(
            $index ?: $this->index,
            $type ?: $this->type
        );
    }
}